package org.act.xservices.rt.xcontainer.service.worker;

import org.act.xservices.rt.xcontainer.framework.IConnector;
import org.act.xservices.rt.xcontainer.framework.dispatcher.ADispatchWorkerFactory;
import org.act.xservices.rt.xcontainer.framework.dispatcher.ISafeDispatchWorker;
import org.act.xservices.rt.xcontainer.inf.context.IMessageContext;
import org.act.xservices.rt.xcontainer.service.handler.MessageDispatchHandler;

/**
 * @LastModifyTime 2008-7-7
 * @CreationTime 2007-06-20
 * @author Lizq [lizq@act.buaa.edu.cn]
 * @since JDK1.5
 */
public class ServiceInWorkerFactory extends ADispatchWorkerFactory<IMessageContext>{

	
	private MessageDispatchHandler messagePoolHandler;
	
	
	
	@SuppressWarnings("unchecked")
	public ServiceInWorkerFactory(IConnector connector){
		super(connector);
	}
	
	
	
	@SuppressWarnings("unchecked")
	@Override
	public final ISafeDispatchWorker createSafeDispatchWorker(IMessageContext messageContext) {
		
		ServiceInWorker serviceInExecutable = 
			new ServiceInWorker(this.getConnector());
		
		serviceInExecutable.setInMessageContext(messageContext);
		serviceInExecutable.setMessageDispatchHandler(messagePoolHandler);
		return serviceInExecutable;
	}



	public MessageDispatchHandler getMessagePoolHandler() {
		return messagePoolHandler;
	}



	public void setMessagePoolHandler(MessageDispatchHandler messagePoolHandler) {
		this.messagePoolHandler = messagePoolHandler;
	}

}
